<template>
    <div
      class="animated-card"
      :class="{ 'is-hoverable': hoverable }"
      @mouseenter="handleMouseEnter"
      @mouseleave="handleMouseLeave"
    >
      <div class="card-content">
        <slot></slot>
      </div>
      <div class="card-shine"></div>
    </div>
  </template>
  
  <script setup>
  import { ref } from 'vue'
  
  const props = defineProps({
    hoverable: {
      type: Boolean,
      default: false
    }
  })
  
  const isHovered = ref(false)
  
  const handleMouseEnter = () => {
    if (props.hoverable) {
      isHovered.value = true
    }
  }
  
  const handleMouseLeave = () => {
    if (props.hoverable) {
      isHovered.value = false
    }
  }
  </script>
  
  <style scoped>
  .animated-card {
    position: relative;
    background: #fff;
    border-radius: var(--border-radius-base);
    box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16),
                0 3px 6px 0 rgba(0, 0, 0, 0.12),
                0 5px 12px 4px rgba(0, 0, 0, 0.09);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
  }
  
  .animated-card.is-hoverable:hover {
    transform: translateY(-4px);
    box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12),
                0 6px 16px 0 rgba(0, 0, 0, 0.08),
                0 9px 28px 8px rgba(0, 0, 0, 0.05);
  }
  
  .card-content {
    position: relative;
    z-index: 1;
  }
  
  .card-shine {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
      45deg,
      transparent 0%,
      rgba(255, 255, 255, 0.1) 50%,
      transparent 100%
    );
    transform: translateX(-100%);
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .animated-card:hover .card-shine {
    transform: translateX(100%);
  }
  
  /* 暗色主题适配 */
  [data-theme='dark'] .animated-card {
    background: #1f1f1f;
  }
  
  /* 动画效果 */
  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .animated-card {
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  }
  </style>